package com.xuecheng.content.api;

import com.xuecheng.content.model.dto.CourseTeacherDto;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class courseTeacherController {
    @Autowired
    private CourseTeacherService courseTeacherService ;

//    获取机构下所有的教师
    @GetMapping("/courseTeacher/list2/{courseId}")
    public List<CourseTeacher> getTeacherList(@PathVariable Long courseId){
        Long companyId = 1232141425l ;
        List<CourseTeacher> list = courseTeacherService.selectByCompanyId(companyId);
//        CourseTeacher courseTeacher = courseTeacherService.getCourseTeacher(courseId);
        return list ;
    }


    //    获取机构下对应课程的教师
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> getTeacherByCourseId(@PathVariable Long courseId){
        Long companyId = 1232141425l ;
        List<CourseTeacher> list = courseTeacherService.selectByCompanyIdAndCourseId(courseId,companyId);
//        CourseTeacher courseTeacher = courseTeacherService.getCourseTeacher(courseId);
        return list ;
    }


//    courseTeacher添加和修改
    @PostMapping("/courseTeacher")
    public CourseTeacher addCourseTeacher(@RequestBody CourseTeacherDto courseTeacherDto){
        CourseTeacher courseTeacher = courseTeacherService.saveCourseTeacher(courseTeacherDto);
        return courseTeacher ;
    }

    @DeleteMapping("/courseTeacher/course/{courseId}/{id}")
    public void deleteCourseTeacher(@PathVariable("courseId") Long courseId,@PathVariable("id") Long id){
        courseTeacherService.deleteCourseTeacher(courseId,id);
    }

}
